package com.crh.service.impl;

import java.sql.Connection;

import com.crh.dao.IGoodsCollectDao;
import com.crh.dao.IGoodsDao;
import com.crh.service.IGoodsService;
import com.crh.utils.DaoFactory;
import com.crh.utils.JdbcUtils;

public class IGoodsServiceImpl implements IGoodsService {

	@Override
	public boolean delGoods(int goodsid) throws Exception {
		IGoodsDao goodsDao = DaoFactory.getInstance().getGoodsDao();
		IGoodsCollectDao goodsCollectDao = DaoFactory.getInstance().getGoodsCollectDao();
		Connection conn = JdbcUtils.getConnection();
		// 取消自动事务的提交，改为手动
		conn.setAutoCommit(false);
		goodsCollectDao.delGoodsCollect(goodsid, conn);
		goodsDao.delGoods(goodsid, conn);
		// 手动提交事务
		conn.commit();
		// 释放资源
		JdbcUtils.free(null, null, conn);
		return false;
	}

}
